import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import { jsx as _jsx } from "react/jsx-runtime";
import { useIntl } from '@ant-design/pro-provider';
import { Input } from 'antd-v4';
import React from 'react';
/**
 * 最基本的组件，就是个普通的 Input.TextArea
 *
 * @param
 */

var FieldTextArea = function FieldTextArea(_ref, ref) {
  var text = _ref.text,
      mode = _ref.mode,
      render = _ref.render,
      renderFormItem = _ref.renderFormItem,
      fieldProps = _ref.fieldProps;
  var intl = useIntl();

  if (mode === 'read') {
    var dom = _jsx("span", {
      ref: ref,
      children: text !== null && text !== void 0 ? text : '-'
    });

    if (render) {
      return render(text, _objectSpread({
        mode: mode
      }, fieldProps), dom);
    }

    return dom;
  }

  if (mode === 'edit' || mode === 'update') {
    var _dom = _jsx(Input.TextArea, _objectSpread({
      ref: ref,
      rows: 3,
      onKeyPress: function onKeyPress(e) {
        if (e.key === 'Enter') e.stopPropagation();
      },
      placeholder: intl.getMessage('tableForm.inputPlaceholder', '请输入')
    }, fieldProps));

    if (renderFormItem) {
      return renderFormItem(text, _objectSpread({
        mode: mode
      }, fieldProps), _dom);
    }

    return _dom;
  }

  return null;
};

export default /*#__PURE__*/React.forwardRef(FieldTextArea);